﻿using OxyPlot.Axes;
using System.Globalization;
using System.Windows.Data;

namespace CoreModule.Converters
{
    /// <summary>
    /// oxyplot Double转换成时间格式
    /// </summary>
    public class DoubleToDateTimeStringConverter : IValueConverter
    {
        /// <summary>
        /// 时间格式化
        /// </summary>
        public string FormatString { get; set; } = "";
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var v = (double)value;
            return DateTimeAxis.ToDateTime(v).ToString(FormatString);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return 0;
        }
    }
}
